#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int p = 998244353;
int dp[1010][20][2][110]; // 第 i 位是 j 时各位数字之和是 k 倍数的个数
int digit[1100];
int cnt;
string s;
int k;

int dfs(int pos,int prev, int limit, int sum){
	if (pos==0) {
		return (sum%k)==0;
	}
	if (dp[pos][prev][limit][sum] != -1) {
		return dp[pos][prev][limit][sum];
	}
	int up = limit?digit[pos]:9;
	int res=0;
	for (int i=0;i<=up;i++) {
		res=(res+dfs(pos-1,i,limit&&(i==up), (sum+i)%k))%p;
	}
	dp[pos][prev][limit][sum]=res;
	return res;
}

void solve(){
	cin>>s;
	cin>>k;
	memset(dp, -1, sizeof(dp));
	reverse(s.begin(), s.end());
	for (int i=1;i<=s.length();i++) {
		digit[i] = s[i-1]-'0';
	}
	cout <<dfs(s.length(), 0, 1, 0)-1<<'\n';
}

signed main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	solve();
	return 0;
}

